package com.we823.project.model.product;

import java.util.List;

import org.apache.commons.lang3.StringUtils;

public class ProcessInfo implements Comparable<ProcessInfo>{
	/**
	 * 工序排序
	 */
	private int orderid=0;
	/**
	 * BOM级别，倒序方式排列，越小越后面
	 */
	private int deep=0;
	/**
	 * BOM计数，用于工序排序
	 */
	private int count=0;
	/**
	 * 工序名称
	 */
	private String name;
	/**
	 * 后序工序
	 */
	private String nextProcess;
	/**
	 * 前序工序
	 */
	private List<String> preProcessList;
	/**
	 * 生产目标物料代号
	 */
	private String code;
	/**
	 * 物料规格
	 */
	private String model;
	/**
	 * 描述，特指颜色
	 */
	private String desc;
	/**
	 * 作用物料代号
	 */
	private String destCode;
	/**
	 * 作用物料名称
	 */
	private String destModel;
	private float totalNum=0;
	/**
	 * 单位
	 */
	private String unit;
	
	/**
	 * 描述
	 */
	private String description;
	
	public int getOrderid() {
		return orderid;
	}
	public void setOrderid(int orderid) {
		this.orderid = orderid;
	}
	public int getDeep() {
		return deep;
	}
	public void setDeep(int deep) {
		this.deep = deep;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getCount() {
		return count;
	}
	public void setCount(int count) {
		this.count = count;
	}
	
	@Override
	public String toString() {
		String preProcess = "";
		if (preProcessList!=null) {
			Object[] preProcesses = preProcessList.toArray();
			preProcess = StringUtils.join(preProcesses,",");
		}
		return "ProcessInfo [preProcess="+preProcess+", name=" + name+ ",nextProcess="+nextProcess+", code="+code+", count=" + count+ ", deep=" + deep+", orderid=" + orderid + ", destCode="+destCode+", destModel="+destModel+"]";
	}
	@Override
	public int compareTo(ProcessInfo o) {
		if (o!=null) {
			if (o.getDeep()==this.deep) {
				return this.orderid - o.getOrderid();
			}else {
				return o.getDeep()-this.deep;
			}
		}
		return 0;
	}

	public String getNextProcess() {
		return nextProcess;
	}
	public void setNextProcess(String nextProcess) {
		this.nextProcess = nextProcess;
	}
	
	public List<String> getPreProcessList() {
		return preProcessList;
	}
	public void setPreProcessList(List<String> preProcessList) {
		this.preProcessList = preProcessList;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getModel() {
		return model;
	}
	public void setModel(String model) {
		this.model = model;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	public float getTotalNum() {
		return totalNum;
	}
	public void setTotalNum(float totalNum) {
		this.totalNum = totalNum;
	}
	public String getUnit() {
		return unit;
	}
	public void setUnit(String unit) {
		this.unit = unit;
	}
	
	
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
	
	public String getDestCode() {
		return destCode;
	}
	public void setDestCode(String destCode) {
		this.destCode = destCode;
	}
	public String getDestModel() {
		return destModel;
	}
	public void setDestModel(String destModel) {
		this.destModel = destModel;
	}
	
	public String getPreProcess() {
		if (preProcessList!=null) {
			Object[] objects = preProcessList.toArray();
			return StringUtils.join(objects,",");
		}
		return "无";
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((code == null) ? 0 : code.hashCode());
		result = prime * result + count;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ProcessInfo other = (ProcessInfo) obj;
		if (code == null) {
			if (other.code != null)
				return false;
		} else if (!code.equals(other.code))
			return false;
		if (count != other.count)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
	
}
